package com.xy.configs;

import com.xy.interceptor.MyHandlerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MySpringMVCConfig  implements WebMvcConfigurer {
		//拦截器注册
		@Override
		public void addInterceptors(InterceptorRegistry registry) {
				//拦截所有请求
				//registry.addInterceptor(getMyInterceptor()).addPathPatterns("/wf-admin/index.html#/**").excludePathPatterns("/wf-admin/static/").excludePathPatterns("/wf-admin/index.html#/login?redirect=%2Findex").excludePathPatterns("/wf-admin/login");
		}
//		@Override
//		public void addResourceHandlers(ResourceHandlerRegistry registry) {
//				registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//				WebMvcConfigurer.super.addResourceHandlers(registry);
//		}
		@Bean
		public HandlerInterceptor getMyInterceptor() {
				return new MyHandlerInterceptor();
		}

}
